home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-02-07 | 1.8 KB | 72 lines | [TEXT/MPS ] |
- (*
- CTBState() -- Return the state of the current connection: "closed", "opening", "open", "closing".
-
- To compile and link this file using Macintosh Programmer's Workshop,
-
- pascal -w CTBState.p
- link -m ENTRYPOINT -o HyperCommands -rt XFCN=2753 -sn Main=CTBState ∂
- CTBState.p.o "{MPW}"Libraries:interface.o "{MPW}"Libraries:Libraries:HyperXLib.o
-
- © Copyright 1990 by Apple Computer, Inc.
-
- Initial coding 2/90 by Harry R. Chesley.
- *)
-
- {$R-}
-
- {$S CTBState } { Segment name must be the same as the command name. }
-
- unit DummyUnit;
-
- interface
-
- uses MemTypes, QuickDraw, OSIntf, ToolIntf, CTBUtils, FTIntf, CMIntf, TMIntf, CRMIntf, HyperXCmd;
-
- procedure EntryPoint(paramPtr: XCmdPtr);
-
- implementation
-
- procedure CTBState(paramPtr: XCmdPtr); forward;
-
- procedure EntryPoint(paramPtr: XCmdPtr);
-
- begin
- CTBState(paramPtr);
- end;
-
- procedure CTBState(paramPtr: XCmdPtr);
-
- {$I CTBUtil.inc}
-
- var sizes: CMBufferSizes;
- status: CMStatFlags;
- s: Str255;
-
- procedure Fail(errMsg: Str255); { set theResult and quit }
- begin
- paramPtr^.returnValue := PasToZero(paramPtr,errMsg);
- exit(CTBState);
- end;
-
- begin
- { Check the parameter count. }
- if paramPtr^.paramCount <> 0 then Fail('Invalid parameter count');
-
- { Make sure the Comm Toolbox is present. }
- CTBReady;
-
- { Convert the state to a string. }
- if Globals^^.connHand = nil then status := 0
- else if CMStatus(Globals^^.connHand,sizes,status) <> noErr then status := 0;
- if (BAnd(status,cmStatusOpening) <> 0) or
- (BAnd(status,cmStatusListenPend+cmStatusIncomingCallPresent) <> 0) then s := 'opening'
- else if BAnd(status,cmStatusClosing) <> 0 then s := 'closing'
- else if BAnd(status,cmStatusOpen) <> 0 then s := 'open'
- else s := 'closed';
-
- { Return it. }
- paramPtr^.returnValue := PasToZero(paramPtr,s);
- end;
-
- end.
-